/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ove.palette.swing;

/**
 *
 * @author Mr.Sam
 */
import javax.swing.*;
import java.util.*;
import fr.ove.palette.swing.*;
import fr.ove.palette.events.*;

/**
* A container containing several palettes.<BR>
* Serves as, some kind of wrappers for palletes.
*
* @author © 1999 DIRAT Laurent
* @version 1.0  20/09/1999
*/
public abstract class PaletteContainer extends JPanel {
    /**
    * the list of palette instances contained.
    */
    private Vector listOfPalettes = new Vector();
    
    /**
    * Adds a palette to the instance.
    * @param palette the palette to add
    */
    public void addPalette(Palette palette) {
        add(palette);
        listOfPalettes.addElement(palette);
    }
    
    // Wrapper methods for the different palettes contained.
    
    /**
    * Registers another listener to be informed of changes of the palette.
    * @param paletteListener a listener to add.
    */
    public void addPaletteListener(PaletteListener paletteListener) {
        for (Enumeration e = listOfPalettes.elements(); e.hasMoreElements(); )
            ((Palette) e.nextElement()).addPaletteListener(paletteListener);
    }

    /**
    * Removes a listener.
    * @param paletteListener the listener to remove.
    */
    public void removePaletteListener(PaletteListener paletteListener) {
        for (Enumeration e = listOfPalettes.elements(); e.hasMoreElements(); )
            ((Palette) e.nextElement()).removePaletteListener(paletteListener);
    }
}    